import 'package:flutter/material.dart';
import 'package:stock_check/common/model/taskItemDetail.dart';

class RenderTaskItemWidget extends StatelessWidget {
  final TaskDetailItem item;
  const RenderTaskItemWidget({Key key, this.item}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var textStyle = TextStyle(color:  Colors.grey[600]);
    return InkWell(
        onTap: (){},
        child: Stack(
          fit: StackFit.passthrough,
          alignment: Alignment.center,
          children: <Widget>[
            Card(
              child: Container(
                  width: double.infinity,
                  padding: EdgeInsets.all(16.0),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment:
                    MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      RichText(text: TextSpan(
                          text: "资产ID:",style: textStyle,
                          children: [
                            TextSpan(
                                text: "  ${item.assetId}",style: textStyle
                            )
                          ]
                      )),
                      Divider(),
                      RichText(text: TextSpan(
                          text: "资产编号:",style: textStyle,
                          children: [
                            TextSpan(
                                text: "  ${item.eqptNo}",style: textStyle
                            )
                          ]
                      )),
                      Divider(),
                      RichText(text: TextSpan(
                          text: "资产地址:",style: textStyle,
                          children: [
                            TextSpan(
                                text: "  ${item.position}",style: textStyle
                            )
                          ]
                      )),
                    ],
                  )),
            ),
            Positioned(
                top: 60.0,
                right: 20,
                width: 100.0,
                height: 40.0,
                child: Container(
                    child: _renderCheckStatus(item.status)
                ))
          ],
        )
    );
  }

  // 渲染盘点状态
  _renderCheckStatus(int status) {
    String text;
    Color color;

    if(status==1){
      text = '未确认';
      color = Colors.red[300];
    }else{
      text = '已确认';
      color = Colors.green;
    }

    return Transform(
      transform: Matrix4.rotationZ(-0.3),
      child: Container(
        width: 80.0,
        height: 40.0,
        alignment: Alignment.center,
        decoration: BoxDecoration(
            border: Border.all(color: color,width: 4.0)
        ),
        child: Text(text, style: TextStyle(color: color, fontWeight: FontWeight.bold)),
      ),
    );
  }
}
